package com.sunlight.boot.codegen;

import com.baomidou.mybatisplus.generator.config.po.TableInfo;

public class CustomTableInfo extends TableInfo {
    private String idPre = "";
    private String idName = "";

    public CustomTableInfo() {
    }

    public String getServiceNameLower() {
        return this.getServiceName().substring(0, 1).toLowerCase() + this.getServiceName().substring(1);
    }

    public String getEntityNameLower() {
        return this.getEntityName().substring(0, 1).toLowerCase() + this.getEntityName().substring(1);
    }

    public String getIdNameUpper() {
        return this.getIdName().substring(0, 1).toUpperCase() + this.getIdName().substring(1);
    }

    public String getTableApi() {
        String name = this.getName();
        char[] chars = name.toCharArray();

        for(int i = 1; i < chars.length; ++i) {
            if ('A' <= chars[i] && 'Z' >= chars[i]) {
                return name.substring(i).toLowerCase();
            }
        }

        return name;
    }

    public String getIdPre() {
        return this.idPre;
    }

    public void setIdPre(String idPre) {
        this.idPre = idPre;
    }

    public String getIdName() {
        return this.idName;
    }

    public void setIdName(String idName) {
        this.idName = idName;
    }
}

